package org.ala.tcp_feign_client.spring;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

/**
 *
 * @author 骆毅(ala)
 * @date 2024年4月23日
 */
@Component
public class TcpFeignClientSpringContext implements ApplicationContextAware {

	
	public static ApplicationContext applicationContext;
	
	
	@Override
	public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
		TcpFeignClientSpringContext.applicationContext = applicationContext;
	}

	
	/**
	 * 拿bean
	 */
	public static <T> T getBeanByClass(Class<T> clazz) {
		return applicationContext.getBean(clazz);
	}
}
